// 对象的混入
interface ObjectA {
  a: string
}

interface ObjectB {
  b: string
}

const Aa: ObjectA = { a: 'a' }
const Bb: ObjectB = { b: 'b' }
const Ab: ObjectA & ObjectB = { ...Aa, ...Bb }

// 类的混入
class ClassAa {
  isA: boolean;
  funcA() {
    console.log('A');
  }
}

class ClassBb {
  isB: boolean;
  funcB() {
    console.log('B');
  }
}

class ClassAB implements ClassAa, ClassBb {
  isA = false;
  isB = false;
  funcA() {}
  funcB() {}
  constructor() {}
}

export function mixins(base: any, from: any[]) {
  from.forEach(item => {
    Object.getOwnPropertyNames(item.prototype).forEach(key => {
      console.log('key', key);
      base.prototype[key] = item.prototype[key];
    })
  })
}

mixins(ClassAB, [ClassAa, ClassBb]);